﻿<Page x:Class="PasswordProvider.View.FileActionsPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:lib="clr-namespace:PasswordProvider.View.Library"
    xmlns:behavior="clr-namespace:PasswordProvider.View.Behaviors"
    Title="{Binding DisplayName}"
    ToolTip="{Binding ToolTip}">      

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <GroupBox Header="Active File:" Grid.Row="0" Margin="5,3,5,0">
            <StackPanel Margin="5,5">
                <TextBox Grid.Row="1" Margin="0,0,0,0" HorizontalAlignment="Stretch" VerticalAlignment="Top"                         
                         IsReadOnly="{Binding ActiveFilePath.IsReadOnly}"
                         IsEnabled="{Binding ActiveFilePath.IsActive}"
                         ToolTip="{Binding ActiveFilePath.ToolTip}"
                         Text="{Binding ActiveFilePath.Text}"
                         />
                <WrapPanel Margin="0,3,0,0" HorizontalAlignment="Center">
                    <Button IsEnabled="{Binding NewCommand.IsEnabled}"
                            Content="{Binding NewCommand.DisplayName}"
                            ToolTip="{Binding NewCommand.ToolTip}"
                            Command="{Binding NewCommand.Command}"
                            />
                    <Button Margin="3,0"
                            IsEnabled="{Binding OpenCommand.IsEnabled}"
                            Content="{Binding OpenCommand.DisplayName}"
                            ToolTip="{Binding OpenCommand.ToolTip}"
                            Command="{Binding OpenCommand.Command}"
                            />
                    <Button IsEnabled="{Binding SaveAsCommand.IsEnabled}"
                            Content="{Binding SaveAsCommand.DisplayName}"
                            ToolTip="{Binding SaveAsCommand.ToolTip}"
                            Command="{Binding SaveAsCommand.Command}"
                            />
                </WrapPanel>
            </StackPanel>
        </GroupBox>

        <GroupBox Grid.Row="1" Margin="5,10,5,0" 
                  Header="{Binding BackupFilePath.DisplayName}" >
            <StackPanel Margin="5,5" HorizontalAlignment="Stretch">
                <Grid>
                    <TextBox Grid.Row="1" Margin="0,0,3,0"
                             VerticalAlignment="Top" HorizontalAlignment="Stretch" 
                             IsReadOnly="{Binding BackupFilePath.IsReadOnly}"
                             IsEnabled="{Binding BackupFilePath.IsEnabled}"
                             ToolTip="{Binding BackupFilePath.ToolTip}"
                             Text="{Binding BackupFilePath.Text}"
                            />
                    <Button HorizontalAlignment="Right"
                            IsEnabled="{Binding BrowseBackupFileCommand.IsEnabled}"
                            ToolTip="{Binding BrowseBackupFileCommand.ToolTip}"
                            Content="{Binding BrowseBackupFileCommand.DisplayName}"
                            Command="{Binding BrowseBackupFileCommand.Command}"
                            />
                </Grid>
                <Grid Margin="0,3,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition/>
                        <RowDefinition/>
                    </Grid.RowDefinitions>
                    <WrapPanel HorizontalAlignment="Center">
                        <TextBlock Margin="0,0,3,0" Text="{Binding FileBackupMode.DisplayName}" />

                        <lib:EnumSelector Mode="ComboBox" EnumValue="{Binding FileBackupMode.EnumValue}">
                            <!-- using the behaviors for support of indexed properties in the path -->
                            <lib:EnumSelectorDisplayItem                                      
                                   DisplayName="{behavior:StringBinding FileBackupMode.DisplayItems[0].DisplayName}"
                                   ToolTip="{behavior:StringBinding FileBackupMode.DisplayItems[0].ToolTip}"
                                   EnumValue="{behavior:EnumBinding FileBackupMode.DisplayItems[0].EnumValue}" />
                            <lib:EnumSelectorDisplayItem
                                   DisplayName="{behavior:StringBinding FileBackupMode.DisplayItems[1].DisplayName}"
                                   ToolTip="{behavior:StringBinding FileBackupMode.DisplayItems[1].ToolTip}"
                                   EnumValue="{behavior:EnumBinding FileBackupMode.DisplayItems[1].EnumValue}" />
                        </lib:EnumSelector>
                    </WrapPanel>
                    <WrapPanel Margin="0,7,0,0" Grid.Row="1" HorizontalAlignment="Center">
                        <Button IsEnabled="{Binding RestoreFromBackupCommand.IsEnabled}"
                                Content="{Binding RestoreFromBackupCommand.DisplayName}"
                                ToolTip="{Binding RestoreFromBackupCommand.ToolTip}"
                                Command="{Binding RestoreFromBackupCommand.Command}"
                                />
                        <Button Margin="5,0,0,0"
                                IsEnabled="{Binding BackupNowCommand.IsEnabled}"
                                Content="{Binding BackupNowCommand.DisplayName}"
                                ToolTip="{Binding BackupNowCommand.ToolTip}"
                                Command="{Binding BackupNowCommand.Command}"
                                />
                    </WrapPanel>
                </Grid>

            </StackPanel>
        </GroupBox>

        <GroupBox Grid.Row="2" Margin="5,10,5,0"
                  Header="{Binding ExportFilePath.DisplayName}">
            <StackPanel Margin="5,5" HorizontalAlignment="Stretch">
                <Grid>
                    <TextBox 
                        IsReadOnly="{Binding ExportFilePath.IsReadOnly}"
                        IsEnabled="{Binding ExportFilePath.IsEnabled}"
                        Text="{Binding ExportFilePath.Text}" />
                    <Button HorizontalAlignment="Right"
                            IsEnabled="{Binding BrowseForExportFileCommand.IsEnabled}"
                            Content="{Binding BrowseForExportFileCommand.DisplayName}"
                            Command="{Binding BrowseForExportFileCommand.Command}"
                            />
                </Grid>
                <Button HorizontalAlignment="Center" Margin="0,3,0,0"
                        IsEnabled="{Binding ExportCommand.IsEnabled}"
                        Content="{Binding ExportCommand.DisplayName}"
                        Command="{Binding ExportCommand.Command}"/>

            </StackPanel>
        </GroupBox>

    </Grid>


</Page>
